
-- --------------------------------------------------
-- Entity Designer DDL Script for SQL Server 2005, 2008, 2012 and Azure
-- --------------------------------------------------
-- Date Created: 02/04/2017 13:48:55
-- Generated from EDMX file: C:\Users\源\Documents\Visual Studio 2013\Projects\CZBK.ShopHeima2\CZBK.ShopHeima2.Model\DataModel.edmx
-- --------------------------------------------------

SET QUOTED_IDENTIFIER OFF;
GO
USE [HeimaShopDb];
GO
IF SCHEMA_ID(N'dbo') IS NULL EXECUTE(N'CREATE SCHEMA [dbo]');
GO

-- --------------------------------------------------
-- Dropping existing FOREIGN KEY constraints
-- --------------------------------------------------

IF OBJECT_ID(N'[dbo].[FK_UserInfoR_UserInfo_ActionInfo]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[R_UserInfo_ActionInfo] DROP CONSTRAINT [FK_UserInfoR_UserInfo_ActionInfo];
GO
IF OBJECT_ID(N'[dbo].[FK_ActionInfoRole_ActionInfo]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[ActionInfoRole] DROP CONSTRAINT [FK_ActionInfoRole_ActionInfo];
GO
IF OBJECT_ID(N'[dbo].[FK_ActionInfoRole_Role]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[ActionInfoRole] DROP CONSTRAINT [FK_ActionInfoRole_Role];
GO
IF OBJECT_ID(N'[dbo].[FK_ActionInfoR_UserInfo_ActionInfo]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[R_UserInfo_ActionInfo] DROP CONSTRAINT [FK_ActionInfoR_UserInfo_ActionInfo];
GO

-- --------------------------------------------------
-- Dropping existing tables
-- --------------------------------------------------

IF OBJECT_ID(N'[dbo].[Product]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Product];
GO
IF OBJECT_ID(N'[dbo].[UserInfo]', 'U') IS NOT NULL
    DROP TABLE [dbo].[UserInfo];
GO
IF OBJECT_ID(N'[dbo].[ActionInfo]', 'U') IS NOT NULL
    DROP TABLE [dbo].[ActionInfo];
GO
IF OBJECT_ID(N'[dbo].[Role]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Role];
GO
IF OBJECT_ID(N'[dbo].[R_UserInfo_ActionInfo]', 'U') IS NOT NULL
    DROP TABLE [dbo].[R_UserInfo_ActionInfo];
GO
IF OBJECT_ID(N'[dbo].[DepartmentSet]', 'U') IS NOT NULL
    DROP TABLE [dbo].[DepartmentSet];
GO
IF OBJECT_ID(N'[dbo].[Property]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Property];
GO
IF OBJECT_ID(N'[dbo].[ActionInfoRole]', 'U') IS NOT NULL
    DROP TABLE [dbo].[ActionInfoRole];
GO

-- --------------------------------------------------
-- Creating all tables
-- --------------------------------------------------

-- Creating table 'Product'
CREATE TABLE [dbo].[Product] (
    [Id] int IDENTITY(1,1) NOT NULL,
    [ProductName] nchar(64)  NULL,
    [Delflag] smallint  NULL,
    [SubTime] datetime  NOT NULL,
    [Remark] nvarchar(256)  NULL,
    [AfterShortName] nvarchar(32)  NOT NULL,
    [BeforeShortName] nvarchar(32)  NOT NULL,
    [ProductCode] nvarchar(64)  NOT NULL,
    [OnShelfDate] datetime  NOT NULL,
    [OffLineDate] datetime  NOT NULL,
    [ProductStatus] int  NOT NULL,
    [Description] nvarchar(256)  NOT NULL
);
GO

-- Creating table 'UserInfo'
CREATE TABLE [dbo].[UserInfo] (
    [Id] int IDENTITY(1,1) NOT NULL,
    [Name] nchar(32)  NULL,
    [Delflag] smallint  NOT NULL,
    [Gender] smallint  NOT NULL,
    [Age] smallint  NULL,
    [Address] nvarchar(256)  NOT NULL,
    [Email] nvarchar(256)  NOT NULL,
    [PhoneNum] nvarchar(15)  NOT NULL,
    [SubTime] datetime  NOT NULL,
    [LastLoginDate] datetime  NOT NULL,
    [LastLoginIP] nvarchar(256)  NOT NULL,
    [ErrorTime] smallint  NOT NULL,
    [Remark] nvarchar(256)  NOT NULL,
    [NickName] nvarchar(64)  NOT NULL,
    [UPwd] nvarchar(256)  NOT NULL
);
GO

-- Creating table 'ActionInfo'
CREATE TABLE [dbo].[ActionInfo] (
    [Id] int IDENTITY(1,1) NOT NULL,
    [AName] nvarchar(256)  NOT NULL,
    [Url] nvarchar(256)  NOT NULL,
    [HttpMethod] nvarchar(256)  NOT NULL,
    [DelFlag] smallint  NOT NULL,
    [SubTime] datetime  NOT NULL,
    [Remark] nvarchar(256)  NULL
);
GO

-- Creating table 'Role'
CREATE TABLE [dbo].[Role] (
    [Id] int IDENTITY(1,1) NOT NULL,
    [RoleName] nvarchar(max)  NOT NULL,
    [DelFlag] smallint  NOT NULL,
    [SubTime] datetime  NOT NULL,
    [Remark] nvarchar(256)  NULL,
    [RoleType] smallint  NOT NULL,
    [UserInfoId] int  NOT NULL
);
GO

-- Creating table 'R_UserInfo_ActionInfo'
CREATE TABLE [dbo].[R_UserInfo_ActionInfo] (
    [Id] int IDENTITY(1,1) NOT NULL,
    [UserInfoId] smallint  NOT NULL,
    [ActionInfoId] smallint  NOT NULL,
    [IsPass] smallint  NOT NULL,
    [UserInfoId1] int  NOT NULL,
    [Sort] int  NOT NULL,
    [ActionInfo_Id] int  NOT NULL
);
GO

-- Creating table 'DepartmentSet'
CREATE TABLE [dbo].[DepartmentSet] (
    [Id] int IDENTITY(1,1) NOT NULL,
    [DepartName] nvarchar(max)  NOT NULL,
    [DelFlag] smallint  NOT NULL,
    [SubTime] datetime  NOT NULL,
    [Remark] nvarchar(256)  NULL
);
GO

-- Creating table 'Property'
CREATE TABLE [dbo].[Property] (
    [Id] int IDENTITY(1,1) NOT NULL,
    [PropertyName] nvarchar(32)  NOT NULL,
    [DelFlag] smallint  NOT NULL,
    [SumTime] datetime  NOT NULL,
    [Remark] nvarchar(256)  NOT NULL
);
GO

-- Creating table 'ActionGroup'
CREATE TABLE [dbo].[ActionGroup] (
    [Id] int IDENTITY(1,1) NOT NULL,
    [GroupName] nvarchar(32)  NOT NULL,
    [DelFlag] smallint  NOT NULL,
    [SubTime] datetime  NOT NULL,
    [Remark] nvarchar(256)  NULL
);
GO

-- Creating table 'PropertyOption'
CREATE TABLE [dbo].[PropertyOption] (
    [Id] int IDENTITY(1,1) NOT NULL,
    [OptionName] nvarchar(32)  NOT NULL,
    [DelFlag] smallint  NOT NULL,
    [SubTime] datetime  NOT NULL,
    [Remark] nvarchar(256)  NOT NULL
);
GO

-- Creating table 'Category'
CREATE TABLE [dbo].[Category] (
    [Id] int IDENTITY(1,1) NOT NULL,
    [CategoryName] nvarchar(32)  NOT NULL,
    [ParentId] int  NOT NULL,
    [Level] int  NOT NULL,
    [TreePath] nvarchar(256)  NOT NULL,
    [IsLeaf] bit  NOT NULL
);
GO

-- Creating table 'ProductSkuSet'
CREATE TABLE [dbo].[ProductSkuSet] (
    [Id] int IDENTITY(1,1) NOT NULL,
    [SkuName] nvarchar(32)  NOT NULL,
    [SkuCode] nvarchar(128)  NOT NULL,
    [DelFlag] smallint  NOT NULL,
    [SubTime] datetime  NOT NULL,
    [Remark] nvarchar(256)  NOT NULL,
    [ProductId] int  NOT NULL
);
GO

-- Creating table 'SkuOption'
CREATE TABLE [dbo].[SkuOption] (
    [Id] int IDENTITY(1,1) NOT NULL,
    [PropId] int  NOT NULL,
    [OptionId] int  NOT NULL,
    [IsEnable] bit  NOT NULL
);
GO

-- Creating table 'ActionInfoRole'
CREATE TABLE [dbo].[ActionInfoRole] (
    [ActionInfo_Id] int  NOT NULL,
    [Role_Id] int  NOT NULL
);
GO

-- Creating table 'UserInfoRole'
CREATE TABLE [dbo].[UserInfoRole] (
    [UserInfo_Id] int  NOT NULL,
    [Role_Id] int  NOT NULL
);
GO

-- Creating table 'ActionGroupActionInfo'
CREATE TABLE [dbo].[ActionGroupActionInfo] (
    [ActionGroup_Id] int  NOT NULL,
    [ActionInfo_Id] int  NOT NULL
);
GO

-- Creating table 'RoleActionGroup'
CREATE TABLE [dbo].[RoleActionGroup] (
    [Role_Id] int  NOT NULL,
    [ActionGroup_Id] int  NOT NULL
);
GO

-- Creating table 'DepartmentRole'
CREATE TABLE [dbo].[DepartmentRole] (
    [Department_Id] int  NOT NULL,
    [Role_Id] int  NOT NULL
);
GO

-- Creating table 'ProductProperty'
CREATE TABLE [dbo].[ProductProperty] (
    [Product_Id] int  NOT NULL,
    [Property_Id] int  NOT NULL
);
GO

-- Creating table 'PropertyOptionProperty'
CREATE TABLE [dbo].[PropertyOptionProperty] (
    [PropertyOption_Id] int  NOT NULL,
    [Property_Id] int  NOT NULL
);
GO

-- Creating table 'ProductCategory'
CREATE TABLE [dbo].[ProductCategory] (
    [Product_Id] int  NOT NULL,
    [Category_Id] int  NOT NULL
);
GO

-- Creating table 'CategoryProperty'
CREATE TABLE [dbo].[CategoryProperty] (
    [Category_Id] int  NOT NULL,
    [Property_Id] int  NOT NULL
);
GO

-- Creating table 'ProductSkuSkuOption'
CREATE TABLE [dbo].[ProductSkuSkuOption] (
    [ProductSku_Id] int  NOT NULL,
    [SkuOption_Id] int  NOT NULL
);
GO

-- --------------------------------------------------
-- Creating all PRIMARY KEY constraints
-- --------------------------------------------------

-- Creating primary key on [Id] in table 'Product'
ALTER TABLE [dbo].[Product]
ADD CONSTRAINT [PK_Product]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [Id] in table 'UserInfo'
ALTER TABLE [dbo].[UserInfo]
ADD CONSTRAINT [PK_UserInfo]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [Id] in table 'ActionInfo'
ALTER TABLE [dbo].[ActionInfo]
ADD CONSTRAINT [PK_ActionInfo]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [Id] in table 'Role'
ALTER TABLE [dbo].[Role]
ADD CONSTRAINT [PK_Role]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [Id] in table 'R_UserInfo_ActionInfo'
ALTER TABLE [dbo].[R_UserInfo_ActionInfo]
ADD CONSTRAINT [PK_R_UserInfo_ActionInfo]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [Id] in table 'DepartmentSet'
ALTER TABLE [dbo].[DepartmentSet]
ADD CONSTRAINT [PK_DepartmentSet]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [Id] in table 'Property'
ALTER TABLE [dbo].[Property]
ADD CONSTRAINT [PK_Property]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [Id] in table 'ActionGroup'
ALTER TABLE [dbo].[ActionGroup]
ADD CONSTRAINT [PK_ActionGroup]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [Id] in table 'PropertyOption'
ALTER TABLE [dbo].[PropertyOption]
ADD CONSTRAINT [PK_PropertyOption]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [Id] in table 'Category'
ALTER TABLE [dbo].[Category]
ADD CONSTRAINT [PK_Category]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [Id] in table 'ProductSkuSet'
ALTER TABLE [dbo].[ProductSkuSet]
ADD CONSTRAINT [PK_ProductSkuSet]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [Id] in table 'SkuOption'
ALTER TABLE [dbo].[SkuOption]
ADD CONSTRAINT [PK_SkuOption]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [ActionInfo_Id], [Role_Id] in table 'ActionInfoRole'
ALTER TABLE [dbo].[ActionInfoRole]
ADD CONSTRAINT [PK_ActionInfoRole]
    PRIMARY KEY CLUSTERED ([ActionInfo_Id], [Role_Id] ASC);
GO

-- Creating primary key on [UserInfo_Id], [Role_Id] in table 'UserInfoRole'
ALTER TABLE [dbo].[UserInfoRole]
ADD CONSTRAINT [PK_UserInfoRole]
    PRIMARY KEY CLUSTERED ([UserInfo_Id], [Role_Id] ASC);
GO

-- Creating primary key on [ActionGroup_Id], [ActionInfo_Id] in table 'ActionGroupActionInfo'
ALTER TABLE [dbo].[ActionGroupActionInfo]
ADD CONSTRAINT [PK_ActionGroupActionInfo]
    PRIMARY KEY CLUSTERED ([ActionGroup_Id], [ActionInfo_Id] ASC);
GO

-- Creating primary key on [Role_Id], [ActionGroup_Id] in table 'RoleActionGroup'
ALTER TABLE [dbo].[RoleActionGroup]
ADD CONSTRAINT [PK_RoleActionGroup]
    PRIMARY KEY CLUSTERED ([Role_Id], [ActionGroup_Id] ASC);
GO

-- Creating primary key on [Department_Id], [Role_Id] in table 'DepartmentRole'
ALTER TABLE [dbo].[DepartmentRole]
ADD CONSTRAINT [PK_DepartmentRole]
    PRIMARY KEY CLUSTERED ([Department_Id], [Role_Id] ASC);
GO

-- Creating primary key on [Product_Id], [Property_Id] in table 'ProductProperty'
ALTER TABLE [dbo].[ProductProperty]
ADD CONSTRAINT [PK_ProductProperty]
    PRIMARY KEY CLUSTERED ([Product_Id], [Property_Id] ASC);
GO

-- Creating primary key on [PropertyOption_Id], [Property_Id] in table 'PropertyOptionProperty'
ALTER TABLE [dbo].[PropertyOptionProperty]
ADD CONSTRAINT [PK_PropertyOptionProperty]
    PRIMARY KEY CLUSTERED ([PropertyOption_Id], [Property_Id] ASC);
GO

-- Creating primary key on [Product_Id], [Category_Id] in table 'ProductCategory'
ALTER TABLE [dbo].[ProductCategory]
ADD CONSTRAINT [PK_ProductCategory]
    PRIMARY KEY CLUSTERED ([Product_Id], [Category_Id] ASC);
GO

-- Creating primary key on [Category_Id], [Property_Id] in table 'CategoryProperty'
ALTER TABLE [dbo].[CategoryProperty]
ADD CONSTRAINT [PK_CategoryProperty]
    PRIMARY KEY CLUSTERED ([Category_Id], [Property_Id] ASC);
GO

-- Creating primary key on [ProductSku_Id], [SkuOption_Id] in table 'ProductSkuSkuOption'
ALTER TABLE [dbo].[ProductSkuSkuOption]
ADD CONSTRAINT [PK_ProductSkuSkuOption]
    PRIMARY KEY CLUSTERED ([ProductSku_Id], [SkuOption_Id] ASC);
GO

-- --------------------------------------------------
-- Creating all FOREIGN KEY constraints
-- --------------------------------------------------

-- Creating foreign key on [UserInfoId1] in table 'R_UserInfo_ActionInfo'
ALTER TABLE [dbo].[R_UserInfo_ActionInfo]
ADD CONSTRAINT [FK_UserInfoR_UserInfo_ActionInfo]
    FOREIGN KEY ([UserInfoId1])
    REFERENCES [dbo].[UserInfo]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_UserInfoR_UserInfo_ActionInfo'
CREATE INDEX [IX_FK_UserInfoR_UserInfo_ActionInfo]
ON [dbo].[R_UserInfo_ActionInfo]
    ([UserInfoId1]);
GO

-- Creating foreign key on [ActionInfo_Id] in table 'ActionInfoRole'
ALTER TABLE [dbo].[ActionInfoRole]
ADD CONSTRAINT [FK_ActionInfoRole_ActionInfo]
    FOREIGN KEY ([ActionInfo_Id])
    REFERENCES [dbo].[ActionInfo]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;
GO

-- Creating foreign key on [Role_Id] in table 'ActionInfoRole'
ALTER TABLE [dbo].[ActionInfoRole]
ADD CONSTRAINT [FK_ActionInfoRole_Role]
    FOREIGN KEY ([Role_Id])
    REFERENCES [dbo].[Role]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_ActionInfoRole_Role'
CREATE INDEX [IX_FK_ActionInfoRole_Role]
ON [dbo].[ActionInfoRole]
    ([Role_Id]);
GO

-- Creating foreign key on [ActionInfo_Id] in table 'R_UserInfo_ActionInfo'
ALTER TABLE [dbo].[R_UserInfo_ActionInfo]
ADD CONSTRAINT [FK_ActionInfoR_UserInfo_ActionInfo]
    FOREIGN KEY ([ActionInfo_Id])
    REFERENCES [dbo].[ActionInfo]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_ActionInfoR_UserInfo_ActionInfo'
CREATE INDEX [IX_FK_ActionInfoR_UserInfo_ActionInfo]
ON [dbo].[R_UserInfo_ActionInfo]
    ([ActionInfo_Id]);
GO

-- Creating foreign key on [UserInfo_Id] in table 'UserInfoRole'
ALTER TABLE [dbo].[UserInfoRole]
ADD CONSTRAINT [FK_UserInfoRole_UserInfo]
    FOREIGN KEY ([UserInfo_Id])
    REFERENCES [dbo].[UserInfo]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;
GO

-- Creating foreign key on [Role_Id] in table 'UserInfoRole'
ALTER TABLE [dbo].[UserInfoRole]
ADD CONSTRAINT [FK_UserInfoRole_Role]
    FOREIGN KEY ([Role_Id])
    REFERENCES [dbo].[Role]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_UserInfoRole_Role'
CREATE INDEX [IX_FK_UserInfoRole_Role]
ON [dbo].[UserInfoRole]
    ([Role_Id]);
GO

-- Creating foreign key on [ActionGroup_Id] in table 'ActionGroupActionInfo'
ALTER TABLE [dbo].[ActionGroupActionInfo]
ADD CONSTRAINT [FK_ActionGroupActionInfo_ActionGroup]
    FOREIGN KEY ([ActionGroup_Id])
    REFERENCES [dbo].[ActionGroup]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;
GO

-- Creating foreign key on [ActionInfo_Id] in table 'ActionGroupActionInfo'
ALTER TABLE [dbo].[ActionGroupActionInfo]
ADD CONSTRAINT [FK_ActionGroupActionInfo_ActionInfo]
    FOREIGN KEY ([ActionInfo_Id])
    REFERENCES [dbo].[ActionInfo]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_ActionGroupActionInfo_ActionInfo'
CREATE INDEX [IX_FK_ActionGroupActionInfo_ActionInfo]
ON [dbo].[ActionGroupActionInfo]
    ([ActionInfo_Id]);
GO

-- Creating foreign key on [Role_Id] in table 'RoleActionGroup'
ALTER TABLE [dbo].[RoleActionGroup]
ADD CONSTRAINT [FK_RoleActionGroup_Role]
    FOREIGN KEY ([Role_Id])
    REFERENCES [dbo].[Role]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;
GO

-- Creating foreign key on [ActionGroup_Id] in table 'RoleActionGroup'
ALTER TABLE [dbo].[RoleActionGroup]
ADD CONSTRAINT [FK_RoleActionGroup_ActionGroup]
    FOREIGN KEY ([ActionGroup_Id])
    REFERENCES [dbo].[ActionGroup]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_RoleActionGroup_ActionGroup'
CREATE INDEX [IX_FK_RoleActionGroup_ActionGroup]
ON [dbo].[RoleActionGroup]
    ([ActionGroup_Id]);
GO

-- Creating foreign key on [Department_Id] in table 'DepartmentRole'
ALTER TABLE [dbo].[DepartmentRole]
ADD CONSTRAINT [FK_DepartmentRole_Department]
    FOREIGN KEY ([Department_Id])
    REFERENCES [dbo].[DepartmentSet]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;
GO

-- Creating foreign key on [Role_Id] in table 'DepartmentRole'
ALTER TABLE [dbo].[DepartmentRole]
ADD CONSTRAINT [FK_DepartmentRole_Role]
    FOREIGN KEY ([Role_Id])
    REFERENCES [dbo].[Role]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_DepartmentRole_Role'
CREATE INDEX [IX_FK_DepartmentRole_Role]
ON [dbo].[DepartmentRole]
    ([Role_Id]);
GO

-- Creating foreign key on [Product_Id] in table 'ProductProperty'
ALTER TABLE [dbo].[ProductProperty]
ADD CONSTRAINT [FK_ProductProperty_Product]
    FOREIGN KEY ([Product_Id])
    REFERENCES [dbo].[Product]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;
GO

-- Creating foreign key on [Property_Id] in table 'ProductProperty'
ALTER TABLE [dbo].[ProductProperty]
ADD CONSTRAINT [FK_ProductProperty_Property]
    FOREIGN KEY ([Property_Id])
    REFERENCES [dbo].[Property]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_ProductProperty_Property'
CREATE INDEX [IX_FK_ProductProperty_Property]
ON [dbo].[ProductProperty]
    ([Property_Id]);
GO

-- Creating foreign key on [PropertyOption_Id] in table 'PropertyOptionProperty'
ALTER TABLE [dbo].[PropertyOptionProperty]
ADD CONSTRAINT [FK_PropertyOptionProperty_PropertyOption]
    FOREIGN KEY ([PropertyOption_Id])
    REFERENCES [dbo].[PropertyOption]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;
GO

-- Creating foreign key on [Property_Id] in table 'PropertyOptionProperty'
ALTER TABLE [dbo].[PropertyOptionProperty]
ADD CONSTRAINT [FK_PropertyOptionProperty_Property]
    FOREIGN KEY ([Property_Id])
    REFERENCES [dbo].[Property]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_PropertyOptionProperty_Property'
CREATE INDEX [IX_FK_PropertyOptionProperty_Property]
ON [dbo].[PropertyOptionProperty]
    ([Property_Id]);
GO

-- Creating foreign key on [Product_Id] in table 'ProductCategory'
ALTER TABLE [dbo].[ProductCategory]
ADD CONSTRAINT [FK_ProductCategory_Product]
    FOREIGN KEY ([Product_Id])
    REFERENCES [dbo].[Product]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;
GO

-- Creating foreign key on [Category_Id] in table 'ProductCategory'
ALTER TABLE [dbo].[ProductCategory]
ADD CONSTRAINT [FK_ProductCategory_Category]
    FOREIGN KEY ([Category_Id])
    REFERENCES [dbo].[Category]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_ProductCategory_Category'
CREATE INDEX [IX_FK_ProductCategory_Category]
ON [dbo].[ProductCategory]
    ([Category_Id]);
GO

-- Creating foreign key on [Category_Id] in table 'CategoryProperty'
ALTER TABLE [dbo].[CategoryProperty]
ADD CONSTRAINT [FK_CategoryProperty_Category]
    FOREIGN KEY ([Category_Id])
    REFERENCES [dbo].[Category]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;
GO

-- Creating foreign key on [Property_Id] in table 'CategoryProperty'
ALTER TABLE [dbo].[CategoryProperty]
ADD CONSTRAINT [FK_CategoryProperty_Property]
    FOREIGN KEY ([Property_Id])
    REFERENCES [dbo].[Property]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_CategoryProperty_Property'
CREATE INDEX [IX_FK_CategoryProperty_Property]
ON [dbo].[CategoryProperty]
    ([Property_Id]);
GO

-- Creating foreign key on [ProductSku_Id] in table 'ProductSkuSkuOption'
ALTER TABLE [dbo].[ProductSkuSkuOption]
ADD CONSTRAINT [FK_ProductSkuSkuOption_ProductSku]
    FOREIGN KEY ([ProductSku_Id])
    REFERENCES [dbo].[ProductSkuSet]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;
GO

-- Creating foreign key on [SkuOption_Id] in table 'ProductSkuSkuOption'
ALTER TABLE [dbo].[ProductSkuSkuOption]
ADD CONSTRAINT [FK_ProductSkuSkuOption_SkuOption]
    FOREIGN KEY ([SkuOption_Id])
    REFERENCES [dbo].[SkuOption]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_ProductSkuSkuOption_SkuOption'
CREATE INDEX [IX_FK_ProductSkuSkuOption_SkuOption]
ON [dbo].[ProductSkuSkuOption]
    ([SkuOption_Id]);
GO

-- Creating foreign key on [ProductId] in table 'ProductSkuSet'
ALTER TABLE [dbo].[ProductSkuSet]
ADD CONSTRAINT [FK_ProductProductSku]
    FOREIGN KEY ([ProductId])
    REFERENCES [dbo].[Product]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_ProductProductSku'
CREATE INDEX [IX_FK_ProductProductSku]
ON [dbo].[ProductSkuSet]
    ([ProductId]);
GO

-- --------------------------------------------------
-- Script has ended
-- --------------------------------------------------